package com.jcp.baselibrary.okhttp3.response;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.jcp.baselibrary.okhttp3.OkHttpUtil;

import okhttp3.Response;

/**
 * Created by ldy on 2015/12/30.
 */
public abstract class OkHttpResBeanHandler<T> extends OkHttpCallback<T> {

    private Gson gson;

    @Override
    protected T parseResponse(Response response) throws Throwable {
        if (gson == null){
            gson = OkHttpUtil.buildGson();
        }
        return gson.fromJson(responseToString(response), getGenericType());
    }
}
